package org.grapes.wine.api.method;

import java.util.EnumSet;

public enum EWineMethod implements IWineMethod, CharSequence {
	// adjoined landscape
	GET_ADJOINED_LANDSCAPE_PRICE("grapes.wine.getAdjoinedLandscapePrice"),
	GET_ADJOINED_LANDSCAPE_LOCATION("grapes.wine.getAdjoinedLandscapeLocation"),
	GET_ADJOINED_LANDSCAPE_DISTANCE("grapes.wine.getAdjoinedLandscapeDistance"),
	GET_ADJOINED_LANDSCAPE_TIME("grapes.wine.getAdjoinedLandscapeTime"),
	// costom
	GET_COSTOM_INTRODUCTION("grapes.wine.getCostomIntroduction"),
	GET_COSTOM_RELATIVE_LANDSCAPE("grapes.wine.getCostomRelativeLandscape"),
	// featured course
	GET_FEATURED_COURSE_INTRODUCTION("grapes.wine.getFeaturedCourseIntroduction"),
	GET_FEATURED_COURSE_DAYSNUM("grapes.wine.getFeaturedCourseDaySum"),
	// hotel info
	GET_HOTELINFO_HOTEL_INTRODUCTION("grapes.wine.getHotelInfoHotelIntroduction"),
	// landscape
	GET_LANDSCAPE_VISIT_TIME("grapes.wine.getLandscapeVisitTime"),
	GET_LANDSCAPE_INTRODUCTION("grapes.wine.getLandscapeIntroduction"),
	GET_LANDSCAPE_TICKET_PRICE("grapes.wine.getLandscapeTicketPrice"),
	GET_LANDSCAPE_SIGHTINVOLVED("grapes.wine.getLandscapeSightInvolved"),
	GET_LANDSCAPE_SERIAL("grapes.wine.getLandscapeSerial"),
	// path2BYD
	GET_PATH2BYD_ROUTE("grapes.wine.getPath2BYDRoute"),
	// yacht
	GET_YACHT_PRICE("grapes.wine.getYachtPrice"),
	GET_YACHT_CAPACITY("grapes.wine.getYachtCapacity"),
	// search
	SEARCH_ADJOINED_LANDSCAPE("grapes.wine.search.adjoinedLandscape"),
	SEARCH_COSTOM("grapes.wine.search.costom"),
	SEARCH_FEATURED_COURSE("grapes.wine.search.featuredCourse"),
	SEARCH_HOTELINFO("grapes.wine.search.hotelInfo"),
	SEARCH_LANDSCAPE("grapes.wine.search.landscape"),
	SEARCH_PATH2BYD("grapes.wine.search.path2BYD"),
	SEARCH_YACHT("grapes.wine.search.yacht"),
	// session
	AUTH_GET_SESSION("grapes.wine.auth.getSession"),
	AUTH_CHECK_APP("grapes.wine.auth.checkApp"),
	AUTH_GET_USERID("grapes.wine.auth.getUserId");
	
	private String methodName;

	private static EnumSet<EWineMethod> preAuth = null;
	private static EnumSet<EWineMethod> postAuth = null;

	public static EnumSet<EWineMethod> preAuthMethods() {
		if (null == preAuth)
			preAuth = EnumSet.of(AUTH_GET_SESSION);
		return preAuth;
	}

	public static EnumSet<EWineMethod> postAuthMethods() {
		if (null == postAuth)
			postAuth = EnumSet.complementOf(preAuthMethods());
		return postAuth;
	}

	EWineMethod(String name) {
		methodName = name;
	}

	public String methodName() {
		return this.methodName;
	}

	public boolean requiresSession() {
		return postAuthMethods().contains(this);
	}

	public char charAt(int index) {
		return this.methodName.charAt(index);
	}

	public int length() {
		return this.methodName.length();
	}

	public CharSequence subSequence(int start, int end) {
		return this.methodName.subSequence(start, end);
	}

	public String toString() {
		return this.methodName;
	}
}
